package lq2133;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
        long a= scan.nextLong();
        long b = scan.nextLong();
        long c = b-a;  // 题意a<b
        long d = c-a%c;
        System.out.println(d);

	}

}
